/* SPU Parallel Elliptic Curve Library - Provides Elliptic Curve Cryptographic
 * functions to the Synergistic Processing Unit target platform
 *
 * Copyright (C) 2008  Michael Annichiarico (mike.gcdeveloper@gmail.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

__inline unsigned int poly_cmpeq(const PFIELD2M A, const PFIELD2M B)
{
  unsigned int i;
  vector unsigned int equal;
  const vector unsigned int *a = (const vector unsigned int*)A->v;
  const vector unsigned int *b = (const vector unsigned int*)B->v;

//	printf("poly_cmpeq(A,B):\n");
//	poly_printnice(A);
//	poly_printnice(B);

  equal = spu_splats((unsigned int)-1);
  for (i=0; i<MAXWORDS; i++) {
    equal = spu_and(equal, spu_cmpeq(a[i], b[i]));
  }
//	printf("poly_cmpeq returning %d\n",  (spu_extract(spu_cmpeq(spu_gather(equal), 15), 0)));
  return (spu_extract(spu_cmpeq(spu_gather(equal), 15), 0));
}
